<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<title>Insert title here</title>
</head>
<body>
	<div th:text="${msg}"></div>
	<h3>当前登录用户：<span th:text="${curUser.userName}"></span>，切换身份为：<shiro:principal/></h3>
    <h2>切换身份</h2>
    <div th:if="${isRunas}==true">
    	上一个身份：<span th:text="${previousUsername}"></span>
        |
        <a th:href="@{/runas/switchBack}">切换回该身份</a>
    </div>
    <h3>切换到其他身份：</h3>
    <table class="table" th:if="${not #lists.isEmpty(toUsers)}">
	  <thead>
		<tr>
		  <th>用户名</th>
		  <th>操作</th>
		</tr>
	  </thead>
	  <tbody>
		<tr th:each="user : ${toUsers}">
		  <td th:text="${user.name}"></td>
		  <td>
        	<a th:href="@{/runas/switchTo/{id}(id=${user.id})}">切换到该身份</a>
          </td>
		</tr>          
      </tbody>
	</table>
	<h3>授予身份给其他人：</h3>
	<table class="table">
	  <thead>
        <tr>
		  <th>用户名</th>
		  <th>操作</th>
        </tr>
	  </thead>
	  <tbody>
		<tr th:each="user : ${allUsers}">
		  <td th:text="${user.name}+${user.id}"></td>
		  <td>
			<a th:if="${#lists.contains(toUsers,user)}" th:href="@{/runas/revoke/{id}(id=${user.id})}">回收身份</a>
			<a th:if="${not #lists.contains(toUsers,user)}" th:href="@{/runas/grant/{id}(id=${user.id})}">授予身份</a>
          </td>
      	</tr>
      </tbody>
    </table>
</body>
</html>